$(function(){
	var domain = $("#domain").val();
	if(domain == ''){
		$.alert("系统异常，请联系管理员");
	}
})

function edit(){
	var newdomain = $("#newdomain").val();
	var domain = $("#domain").val();
	if(newdomain != null && newdomain.length > 0){
		if(newdomain == domain){
			$.alert("新域名与老域名相同");
		} else {
			var reg = /^(?![0-9]+$)[0-9A-Za-z]{6,10}$/;
			if(reg.test(newdomain)){
				$.showLoading();
				$.ajax({
					type : "post",
					url : appPath + "/domain/edit.html",
					data : {
						token : $.cookie("token"),
						newdomain : $("#newdomain").val()
					},
					success : function(result) {
						$.hideLoading();
						$.alert(result.msg, function(){
							if (result.code == '1') {
								var ua = navigator.userAgent.toLowerCase();
								if (ua.match(/MicroMessenger/i) == "micromessenger" || /(applewebkitapp)/i.test(ua) || /(androidapp)/i.test(ua)) {
									location.replace("http://www.xinghaoshangcheng.com/center/center.html?token=" + $.cookie('token'));
								} else {
									gotoHtml('/center/center.html');
								}
							}
						});
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						$.hideLoading();
						$.alert("系统异常，请稍后再试");
					}
				});
			} else {
				$.alert("域名必须是6-10位字母或字母和数字的组合");
			}
		}
	} else {
		$.alert("新域名不能为空");
	}
}